export class EventBus {
  constructor () {
    // 所有事件推送（按照map结构，不允许重复）
    this.eventMap = new Map()
    // 未消费的map
    this.omissionEventMap = new Map()
  }

  on (eventName, callback) {
    this.eventMap.set(eventName, callback)
  }

  emit (eventName, payload) {
    const callback = this.eventMap.get(eventName)
    if (callback instanceof Function) {
      callback(payload)
    }
  }

  off (eventName) {
    this.eventMap.delete(eventName)
  }

  clear () {
    this.eventMap.clear()
  }
}
